package com.sq.activity.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sq.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sq.common.annotation.Log;
import com.sq.common.core.controller.BaseController;
import com.sq.common.core.domain.AjaxResult;
import com.sq.common.enums.BusinessType;
import com.sq.activity.domain.ActivityPublisherApply;
import com.sq.activity.service.IActivityPublisherApplyService;
import com.sq.common.utils.poi.ExcelUtil;
import com.sq.common.core.page.TableDataInfo;

/**
 * 申请信息Controller
 * 
 * @author shan
 * @date 2025-02-12
 */
@RestController
@RequestMapping("/activity/apply")
@Api(tags = "申请信息相关接口")
public class ActivityPublisherApplyController extends BaseController
{
    @Autowired
    private IActivityPublisherApplyService activityPublisherApplyService;

    /**
     * 查询申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('activity:apply:list')")
    @GetMapping("/list")
    @ApiOperation(value = "获取申请信息列表")
    public TableDataInfo<List<ActivityPublisherApply>> list(ActivityPublisherApply activityPublisherApply) {
        startPage();
        List<ActivityPublisherApply> list = activityPublisherApplyService.selectActivityPublisherApplyList(activityPublisherApply);
        return getDataTable(list);
    }

    /**
     * 导出申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('activity:apply:export')")
    @Log(title = "申请信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出申请信息列表")
    public void export(HttpServletResponse response, ActivityPublisherApply activityPublisherApply)
    {
        List<ActivityPublisherApply> list = activityPublisherApplyService.selectActivityPublisherApplyList(activityPublisherApply);
        ExcelUtil<ActivityPublisherApply> util = new ExcelUtil<ActivityPublisherApply>(ActivityPublisherApply.class);
        util.exportExcel(response, list, "申请信息数据");
    }

    /**
     * 获取申请信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:apply:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取申请信息详细信息")
    public R<ActivityPublisherApply> getInfo(@ApiParam(value = "申请信息ID", required = true)
            @PathVariable("id") Long id)
    {
        return R.ok(activityPublisherApplyService.selectActivityPublisherApplyById(id));
    }

    /**
     * 新增申请信息
     */
    @PreAuthorize("@ss.hasPermi('activity:apply:add')")
    @Log(title = "申请信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增申请信息")
    public AjaxResult add(@ApiParam(value = "申请信息实体", required = true) @RequestBody ActivityPublisherApply activityPublisherApply) {
        return toAjax(activityPublisherApplyService.insertActivityPublisherApply(activityPublisherApply));
    }

    /**
     * 修改申请信息
     */
    @PreAuthorize("@ss.hasPermi('activity:apply:edit')")
    @Log(title = "申请信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改申请信息")
    public AjaxResult edit(@ApiParam(value = "申请信息实体", required = true) @RequestBody ActivityPublisherApply activityPublisherApply)
    {
        return toAjax(activityPublisherApplyService.updateActivityPublisherApply(activityPublisherApply));
    }

    /**
     * 删除申请信息
     */
    @PreAuthorize("@ss.hasPermi('activity:apply:remove')")
    @Log(title = "申请信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除申请信息")
    public AjaxResult remove(@ApiParam(value = "要删除的数据id的数组") @PathVariable Long[] ids)
    {
        return toAjax(activityPublisherApplyService.deleteActivityPublisherApplyByIds(ids));
    }
}
